<template>
    <div>
        <el-form ref="form">

            <el-form-item>
                <el-input v-model="totalMoney" class="h-40 w-200" placeholder="平台总利润" :maxlength="255"></el-input>
                <el-button type="primary" @click="settlePost">发放分红</el-button>
            </el-form-item>
            <el-form-item>
                <el-button type="danger" @click="dialogFormVisible=true">结算到现金账户</el-button>
            </el-form-item>
        </el-form>
        <el-dialog title="提示" center :visible.sync="dialogFormVisible" width="30%">
            <div>确定结算吗？</div>
            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisible = false">取 消</el-button>
                <el-button type="primary" @click="settleGet">确 定</el-button>
            </div>
        </el-dialog>
    </div>

</template>
<script>
import http from "assets/js/http.js";
export default {
  data() {
    return {
      dialogFormVisible: false,
      totalMoney: "",
      config: {
        baseApi: "pudu/Settle"
      }
    };
  },
  created() {
    _g.closeGlobalLoading();
  },
  methods: {
    settleGet() {
      let url = this.config.baseApi;
      this.apiGet(url).then(res => {
        this.handelResponse(res, data => {
          _g.toastMsg("success", '转换成功!');
          setTimeout(() => {
            _g.shallowRefresh(this.$route.name);
          }, 500);
        });
      });
    },
    settlePost() {
      if (this.totalMoney == "") {
        _g.toastMsg("warning", "请填写平台总利润");
        return;
      }
      let url = this.config.baseApi;
      this.apiPost(url, {
        totalMoney: this.totalMoney
      }).then(res => {
        this.handelResponse(res, data => {
          _g.toastMsg("success", "发放成功");
          setTimeout(() => {
            _g.shallowRefresh(this.$route.name);
          }, 500);
        });
      });
    }
  },
  created(){
      _g.closeGlobalLoading();
  },
  mixins: [http]
};
</script>
<style>

</style>

